//
// Created by 25313 on 2025/8/5.
//
class Solution {
public:
    int floor(int x)
    {
        return x / 2;
    }
    int minStoneSum(vector<int>& piles, int k) {
        priority_queue<int> max_queue(piles.begin(),piles.end());
        int res = 0;
        for(int i = 0 ; i < k ; i++)
        {
            int x = max_queue.top();
            x = x - floor(x);
            max_queue.pop();
            max_queue.push(x);
        }
        while(!max_queue.empty())
        {
            int y = max_queue.top();
            res += y;
            max_queue.pop();
        }
        return res;
    }
};